Mining is the process of assembling transaction blocks and discovering “correct” hash values for them. Instead of just running the SHA-256 function on the data of the block to produce an output, Bitcoin requires that the first however many bits of the resultant hash are 0 (i.e. that the hash is lower than a given value). To do this, miners use computational resources to pair the block data with a random number – a nonce – and run it through the function until the output is one with the desired number of 0s (see below for a real example from blockchain.info). This is a process known as hashing, which is where you get the term hash rate from. A miner that can hash at 1 MegaHash per second is guessing roughly one million nonce values every second. Once the nonce is discovered, the assembled block is then broadcast and added to the blockchain, and the process begins anew.
The number of 0s required for a block's hash (known as the difficulty) is increased or decreased in order to keep block creation at around 10 minutes (another characteristic that can vary by coin) – achieved using a formula that refers back to the timestamps of previous blocks to assess how fast they were created, meaning difficulty responds to increases or decreases in the network’s overall hash rate. If the requirement is that the first 32 characters are 0, the probability of a random data set producing an output that matches this is one in 2^32, or roughly one in four billion, so that's how many values would need to be guessed on average before a suitable output was produced.
Performing many simple calculations per second is the hallmark of GPUs, and it is precisely this reason that the cryptocurrency bubble has inflated demand and end-user costs for graphics cards so much. With Bitcoin, dedicated ASICs that are even faster have replaced GPUs as the primary miners, but GPUs are still relevant to many popular cryptocurrencies.
In return for a miner successfully hashing a block, the Bitcoin network generates new Bitcoins and rewards them to the miner, or rather the mining pool to which the individual miner belongs, which then distributes the reward according to each miner’s hash rate contribution. They can also collect transaction fees from within that block. Miners can actually pick any transactions from the pool that are not yet in the blockchain; a higher fee tends to make a transaction more likely to be chosen. And thus we have clear financial incentives for mining cryptocurrency.
The block rewards are the only way that new currency is added to the overall pool, and inflation is contained by halving the reward after a certain number of blocks (every 210,000 or so in the case of Bitcoin). There is an overall coin cap, too (21 million for Bitcoin). In this way, currency production and inflation is controlled by the system as a whole at a rate that's publicly known from the start rather than being decided behind closed doors and based on the inherently debt-based and inflationary fractional reserve system of modern banking.
Once the network nodes receive blocks, they're able to verify that the block’s hash: matches the expected difficulty, correctly refers back to the previous block, and has a correct proof of work associated with it (the nonce). They then add it to their copy of the digital ledger, thus verifying all the transactions within it, making them available to spend. The correctly calculated hash can then be given to miners, who use this to immediately start working on the next block in the chain, and so on.
October 14 2021 | 15:04
Want to comment? Please log in.